function loadPaths(option)
%By default, adds all necessary filelocations and paths to the Matlab searchpath.
%By using 'unload' as option, it removes all created folders and paths.
% It creates a temp folder for our application as well, and deletes it
% after closing down our application.

%% Create
if ~exist('option')
    %% Adds temp folder
    mkdir('.\Core\temp') % creates a temp folder
    fileattrib('.\Core\temp','+w') % sets fileattrib so we may edit it
    if exist('SaveFiles','dir') ~= 7; % In case a SaveFiles dir doesn't exit
        mkdir('.\SaveFiles') % it creates one
    end
    %% Adds all required system paths (needed for matlab)
    addpath('.\Core')
    addpath('.\Core\temp')
    addpath('.\Core\SAVELOAD')
    addpath('.\GUI')
    addpath('.\SaveFiles')
    
elseif strcmp(option,'unload')
    %% Removes all required and previously added system paths
    % To avoid slowing Matlab down too much for the next application
    rmpath('.\Core')
    rmpath('.\Core\temp')
    rmpath('.\Core\SAVELOAD')
    rmpath('.\GUI')
    rmpath('.\SaveFiles')
    
    %% Removes temp folder
    rmdir('.\Core\temp','s') % 's' indicates all files and subfolders as well
end
end